home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / DefaultButtonModel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  4.8 KB  |  216 lines

  1. package javax.swing;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.awt.event.ItemEvent;
  6. import java.awt.event.ItemListener;
  7. import java.io.Serializable;
  8. import javax.swing.event.ChangeEvent;
  9. import javax.swing.event.ChangeListener;
  10. import javax.swing.event.EventListenerList;
  11.  
  12. public class DefaultButtonModel implements ButtonModel, Serializable {
  13.    protected int stateMask = 0;
  14.    protected String actionCommand = null;
  15.    protected ButtonGroup group = null;
  16.    protected int mnemonic = 0;
  17.    protected transient ChangeEvent changeEvent = null;
  18.    protected EventListenerList listenerList = new EventListenerList();
  19.    public static final int ARMED = 1;
  20.    public static final int SELECTED = 2;
  21.    public static final int PRESSED = 4;
  22.    public static final int ENABLED = 8;
  23.    public static final int ROLLOVER = 16;
  24.    // $FF: synthetic field
  25.    static Class class$javax$swing$event$ChangeListener;
  26.    // $FF: synthetic field
  27.    static Class class$java$awt$event$ActionListener;
  28.    // $FF: synthetic field
  29.    static Class class$java$awt$event$ItemListener;
  30.  
  31.    public DefaultButtonModel() {
  32.       this.stateMask = 0;
  33.       this.setEnabled(true);
  34.    }
  35.  
  36.    public void addActionListener(ActionListener var1) {
  37.       this.listenerList.add(class$java$awt$event$ActionListener != null ? class$java$awt$event$ActionListener : (class$java$awt$event$ActionListener = class$("java.awt.event.ActionListener")), var1);
  38.    }
  39.  
  40.    public void addChangeListener(ChangeListener var1) {
  41.       this.listenerList.add(class$javax$swing$event$ChangeListener != null ? class$javax$swing$event$ChangeListener : (class$javax$swing$event$ChangeListener = class$("javax.swing.event.ChangeListener")), var1);
  42.    }
  43.  
  44.    public void addItemListener(ItemListener var1) {
  45.       this.listenerList.add(class$java$awt$event$ItemListener != null ? class$java$awt$event$ItemListener : (class$java$awt$event$ItemListener = class$("java.awt.event.ItemListener")), var1);
  46.    }
  47.  
  48.    // $FF: synthetic method
  49.    static Class class$(String var0) {
  50.       try {
  51.          return Class.forName(var0);
  52.       } catch (ClassNotFoundException var2) {
  53.          throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  54.       }
  55.    }
  56.  
  57.    protected void fireActionPerformed(ActionEvent var1) {
  58.       Object[] var2 = this.listenerList.getListenerList();
  59.  
  60.       for(int var3 = var2.length - 2; var3 >= 0; var3 -= 2) {
  61.          if (var2[var3] == (class$java$awt$event$ActionListener != null ? class$java$awt$event$ActionListener : (class$java$awt$event$ActionListener = class$("java.awt.event.ActionListener")))) {
  62.             ((ActionListener)var2[var3 + 1]).actionPerformed(var1);
  63.          }
  64.       }
  65.  
  66.    }
  67.  
  68.    protected void fireItemStateChanged(ItemEvent var1) {
  69.       Object[] var2 = this.listenerList.getListenerList();
  70.  
  71.       for(int var3 = var2.length - 2; var3 >= 0; var3 -= 2) {
  72.          if (var2[var3] == (class$java$awt$event$ItemListener != null ? class$java$awt$event$ItemListener : (class$java$awt$event$ItemListener = class$("java.awt.event.ItemListener")))) {
  73.             ((ItemListener)var2[var3 + 1]).itemStateChanged(var1);
  74.          }
  75.       }
  76.  
  77.    }
  78.  
  79.    protected void fireStateChanged() {
  80.       Object[] var1 = this.listenerList.getListenerList();
  81.  
  82.       for(int var2 = var1.length - 2; var2 >= 0; var2 -= 2) {
  83.          if (var1[var2] == (class$javax$swing$event$ChangeListener != null ? class$javax$swing$event$ChangeListener : (class$javax$swing$event$ChangeListener = class$("javax.swing.event.ChangeListener")))) {
  84.             if (this.changeEvent == null) {
  85.                this.changeEvent = new ChangeEvent(this);
  86.             }
  87.  
  88.             ((ChangeListener)var1[var2 + 1]).stateChanged(this.changeEvent);
  89.          }
  90.       }
  91.  
  92.    }
  93.  
  94.    public String getActionCommand() {
  95.       return this.actionCommand;
  96.    }
  97.  
  98.    public int getMnemonic() {
  99.       return this.mnemonic;
  100.    }
  101.  
  102.    public Object[] getSelectedObjects() {
  103.       return null;
  104.    }
  105.  
  106.    public boolean isArmed() {
  107.       return (this.stateMask & 1) != 0;
  108.    }
  109.  
  110.    public boolean isEnabled() {
  111.       return (this.stateMask & 8) != 0;
  112.    }
  113.  
  114.    public boolean isPressed() {
  115.       return (this.stateMask & 4) != 0;
  116.    }
  117.  
  118.    public boolean isRollover() {
  119.       return (this.stateMask & 16) != 0;
  120.    }
  121.  
  122.    public boolean isSelected() {
  123.       return (this.stateMask & 2) != 0;
  124.    }
  125.  
  126.    public void removeActionListener(ActionListener var1) {
  127.       this.listenerList.remove(class$java$awt$event$ActionListener != null ? class$java$awt$event$ActionListener : (class$java$awt$event$ActionListener = class$("java.awt.event.ActionListener")), var1);
  128.    }
  129.  
  130.    public void removeChangeListener(ChangeListener var1) {
  131.       this.listenerList.remove(class$javax$swing$event$ChangeListener != null ? class$javax$swing$event$ChangeListener : (class$javax$swing$event$ChangeListener = class$("javax.swing.event.ChangeListener")), var1);
  132.    }
  133.  
  134.    public void removeItemListener(ItemListener var1) {
  135.       this.listenerList.remove(class$java$awt$event$ItemListener != null ? class$java$awt$event$ItemListener : (class$java$awt$event$ItemListener = class$("java.awt.event.ItemListener")), var1);
  136.    }
  137.  
  138.    public void setActionCommand(String var1) {
  139.       this.actionCommand = var1;
  140.    }
  141.  
  142.    public void setArmed(boolean var1) {
  143.       if (this.isArmed() != var1 && this.isEnabled()) {
  144.          if (var1) {
  145.             this.stateMask |= 1;
  146.          } else {
  147.             this.stateMask &= -2;
  148.          }
  149.  
  150.          this.fireStateChanged();
  151.       }
  152.    }
  153.  
  154.    public void setEnabled(boolean var1) {
  155.       if (this.isEnabled() != var1) {
  156.          if (var1) {
  157.             this.stateMask |= 8;
  158.          } else {
  159.             this.stateMask &= -9;
  160.          }
  161.  
  162.          this.fireStateChanged();
  163.       }
  164.    }
  165.  
  166.    public void setGroup(ButtonGroup var1) {
  167.       this.group = var1;
  168.    }
  169.  
  170.    public void setMnemonic(int var1) {
  171.       this.mnemonic = var1;
  172.       this.fireStateChanged();
  173.    }
  174.  
  175.    public void setPressed(boolean var1) {
  176.       if (this.isPressed() != var1 && this.isEnabled()) {
  177.          if (var1) {
  178.             this.stateMask |= 4;
  179.          } else {
  180.             this.stateMask &= -5;
  181.          }
  182.  
  183.          if (!this.isPressed() && this.isArmed()) {
  184.             this.fireActionPerformed(new ActionEvent(this, 1001, this.getActionCommand()));
  185.          }
  186.  
  187.          this.fireStateChanged();
  188.       }
  189.    }
  190.  
  191.    public void setRollover(boolean var1) {
  192.       if (this.isRollover() != var1 && this.isEnabled()) {
  193.          if (var1) {
  194.             this.stateMask |= 16;
  195.          } else {
  196.             this.stateMask &= -17;
  197.          }
  198.  
  199.          this.fireStateChanged();
  200.       }
  201.    }
  202.  
  203.    public void setSelected(boolean var1) {
  204.       if (this.isSelected() != var1) {
  205.          if (var1) {
  206.             this.stateMask |= 2;
  207.          } else {
  208.             this.stateMask &= -3;
  209.          }
  210.  
  211.          this.fireItemStateChanged(new ItemEvent(this, 701, this, var1 ? 1 : 2));
  212.          this.fireStateChanged();
  213.       }
  214.    }
  215. }
  216.